package com.ny.mapper;

import com.ny.entity.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

    @Insert("insert into user(username,password,nickname,phone,email,is_active) values(#{username},#{password},#{nickname},#{phone},#{email},#{isActive})")
    int addUser(User user);
    // 根据用户名和加密后的密码查询用户
    @Select("select * from user where username= #{username} and password =#{password}")
    public User findUser(@Param("username") String username, @Param("password") String password);
    
    // 根据用户名查询用户（用于处理明文密码）
    @Select("select * from user where username= #{username}")
    public User findUserByName(@Param("username") String username);
    
//邮箱查询用户信息
    @Select("select * from user where email= #{email}")
    public User findUserByEmail(String email);

    @Update("update user set password = #{password} where email = #{email}")
    public int updatePassword(@Param("password") String password, @Param("email") String email);

}